$(function () {
    //变量抽取
    var claims_dataGrid = $("#claims_dataGrid");

    claims_dataGrid.datagrid({
        fitColumns: true,//列自适应
        url: "/charts/claimByGroup.do",
        fit: true,
        columns: [[
            {field: 'groupType', title: '分组类型', width: 100,align:'center'},
            {field: 'totalNumber', title: '理赔总金额', width: 100,align:'center'},
        ]],
        toolbar: "#tb",//工具
        pagination: true,//分页
        rownumbers: true,//行号
        singleSelect: true//只允许选择一行
    });

    var methodObj = {
        search: function () {
            var companyId = $("[name=companyId]").val();
            var beginTime = $("[name=beginTime]").val();
            var endTime = $("[name=endTime]").val();
            var groupType = $("[name=groupType]").val();

            claims_dataGrid.datagrid('load', {
                companyId:companyId,
                beginTime:beginTime,
                endTime:endTime,
                groupType:groupType
            });
        },
        reload:function () {
            claims_dataGrid.dialog("load");
        },
        bar: function () {
            /*点击序列化表单,并且在子窗口中打开拼接的连接地址*/
            var url = "/charts/claimsbar.do";
            url = url + "?" + $("#claimsForm").serialize();
            art.dialog.open(url,{
                width: 800,
                height: 600
            });
        },
        pie: function () {
            /*点击序列化表单,并且在子窗口中打开拼接的连接地址*/
            var url = "/charts/claimspie.do";
            url = url + "?" + $("#claimsForm").serialize();
            art.dialog.open(url,{
                width: 800,
                height: 600
            });
        }

    };

    //按钮统一绑定事件
    $("a[data-cmd]").click(function () {
        var cmd = $(this).data("cmd");
        methodObj[cmd]();
    });
})
